package club.hicode.daydayup.threadpool;

import cn.hutool.core.util.RandomUtil;
import org.junit.Test;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * 测试流
 *
 * @author Liu Chunfu
 * @date 2018-06-26 上午10:55
 **/
public class StreamTest {

    @Test
    public void test1() {
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < 10000000; i++) {
            list.add(RandomUtil.randomInt(10000));
        }

        //第一次
        long start = System.nanoTime();
        List<Integer> collect = list.stream().sorted().collect(Collectors.toList());

        long middle = System.nanoTime();
        System.out.println("stream：" + (middle - start) / 1000 / 1000);

        List<Integer> collect2 = list.parallelStream().sorted().collect(Collectors.toList());
        long end = System.nanoTime();

        System.out.println("end：" + (end - middle) / 1000 / 1000);

    }

    @Test
    public void testForeach() {
        List<Integer> list = new ArrayList<>();
    }
}
